package com.ningxun.rms.utils;

import com.ningxun.rms.common.core.domain.model.LoginUser;
import com.ningxun.rms.common.exception.ServiceException;
import com.ningxun.rms.common.utils.SecurityUtils;
import com.ningxun.rms.domain.busrequire.BusRequire;

public class DataPermissionUtils {
    public static void checkPermission(BusRequire busRequire) {
        LoginUser user = SecurityUtils.getLoginUser();
        // 管理员跳过校验
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if (loginUser.getUser().isAdmin()) {
            return;
        }

        // 校验部门匹配
        if (!user.getDeptId().equals(busRequire.getDeptId())) {
            throw new ServiceException("无权限操作此数据");
        }
    }
}